package com.lin.spbkdt.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author 九分石人
 */
@Slf4j
@Component
public class KafkaConsumerService {

    @KafkaListener(groupId = "test1", topics = "test1")
    public void onMessage(ConsumerRecord<String, Object> consumerRecord, Acknowledgment acknowledgment, Consumer<?, ?> consumer) {
        log.info("消费端接受消息：{}", consumerRecord.value());
        // 手动签收
        acknowledgment.acknowledge();
    }


}
